<title>资金流水</title>
<!--<div class="layui-card-header layui-card">-->
    <!--<span class="layui-breadcrumb" lay-filter="breadcrumb">-->
        <!--<a lay-href="">首页</a>-->
        <!--<a><cite>资金流水</cite></a>-->
    <!--</span>-->
<!--</div>-->


<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-tab-content">
            <div class="layui-btn-group demoTable lay-mb15">
                <div class="layui-form layui-card-header layuiadmin-card-header-auto" lay-filter="layadmin-useradmin-formlist">
                    <div class="layui-form-item" style="margin:0;">
                        <div class="layui-form-item" style="margin:0;">
                            <div class="layui-inline">
                                <label class="layui-form-label">业务订单</label>
                                <div class="layui-input-block">
                                    <input type="text" name="orderId" id="orderId" placeholder="业务订单" autocomplete="off" class="layui-input">

                                </div>
                            </div>

                            <div class="layui-inline">
                                <button id="search" class="layui-btn layuiadmin-btn-admin" data-type="reload">
                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                </button>
                            </div>

                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-card-body">
                <div style="padding-bottom: 10px;">

                    <!--<button id="addChannelMch" class="layui-btn layui-btn-normal" data-type="add"><i class="layui-icon"></i>添加-->
                    <!--</button>-->
                    <!--<button id= "output" class="layui-btn layui-btn-warm" data-type="output"><i class="layui-icon layui-icon-download-circle"></i>导出-->
                    <!--</button>-->
                    <!--<button id= "batchdel" class="layui-btn layui-btn-danger" data-type="batchdel"><i class="layui-icon"></i>删除-->
                    <!--</button>-->
                </div>
                <table id="zjlsList" lay-filter="zjlsList"></table>
            </div>
        </div>
    </div>
</div>

<script>
     //标题内容模板
     var tplTitle = function(d){
        return '<a class="layui-btn layui-btn-xs layui-btn-primary" lay-href="agent/history/detail/id='+ d.id +'">查看</a> '
     };

     layui.use(['table','util','form'], function(){
        var table = layui.table
        ,$ = layui.$
        ,form = layui.form
        ,element = layui.element;

        element.render('breadcrumb', 'breadcrumb');//渲染导航信息

         var tplAmount = function(d){
             if(d.fundDirection == 1) {
                 return "<span style='color: darkgreen'>+ " + d.amount/100 + "</span>";
             }else if(d.fundDirection == 2) {
                 return "<span style='color: orangered'>- " +  d.amount/100 + "</span>";
             }
         };

        table.render({
            elem: '#zjlsList'
            ,url: layui.setter.baseUrl + '/agent_account/history_list'
            ,where: {
                access_token: layui.data(layui.setter.tableName).access_token
            }
            ,id: 'tableReload'
            ,cols: [[
                {field:'agentId', title: '代理商ID', sort: true }
                ,{field: 'balance',title: '变更前余额(元)',templet: '<div>{{d.balance/100}}</div>'}
                ,{field: 'amount',title: '变更金额(元)',templet: tplAmount}
                ,{field: 'afterBalance',title: '变更后余额(元)',templet: '<div>{{d.afterBalance/100}}</div>'}
                ,{field: 'bizType',title: '业务类型',templet: '<div>{{d.bizType == 1?"分润":d.bizType == 2?"提现":d.bizType == 3?"调账":""}}</div>'}
                ,{field: 'bizItem',title: '业务类目',templet: '<div>{{d.bizItem == 10?"余额":d.bizItem == 20?"支付":d.bizItem == 21?"代付":d.bizItem == 22?"线下充值":d.bizItem == 23?"线上充值":""}}</div>'}
                ,{field: 'orderId',title: '业务订单' ,width: 270}
                ,{field:'createTime',  title: '时间', templet: '<div>{{ layui.util.toDateString(d.createTime) }}</div>' }
                ,{field:'edite', title: '操作', templet: tplTitle }
            ]]
            ,page: true
            ,skin: 'line'
        });

        // 搜索
        var $ = layui.$, active = {
            reload: function(){
                var orderId = $('#orderId').val();
                //执行重载
                table.reload('tableReload', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    ,where: {
                        orderId: orderId
                    }
                });
            }
        };
        $('#search').on('click', function() {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

        // 渲染表单
        form.render();


     })
</script>